package cn.gson.springboot.model.pojos;

import javax.persistence.*;
import java.sql.Date;
import java.util.Collection;
import java.util.Objects;

@Entity
@Table(name = "outbound_", schema = "crm")
public class Outbound {
    private int outboundId;
    private String outboundTitle;
    private String outboundStatus;
    private Date outboundDate;
    private String outboundEmpName;
    private String outboundExecutor;
    private Date outboundExecutorDate;
    private String outboundNo;
    private String outboundNote;
    private String outboundCustomerName;
    private Contract contractByContractId;
    private Warehouse warehouseByWarehouseId;
    private Collection<OutboundDetail> outboundDetailsByOutboundId;

    @Id
    @Column(name = "outbound_id", nullable = false)
    public int getOutboundId() {
        return outboundId;
    }

    public void setOutboundId(int outboundId) {
        this.outboundId = outboundId;
    }


    @Basic
    @Column(name = "outbound_title", nullable = true, length = 255)
    public String getOutboundTitle() {
        return outboundTitle;
    }

    public void setOutboundTitle(String outboundTitle) {
        this.outboundTitle = outboundTitle;
    }

    @Basic
    @Column(name = "outbound_status", nullable = true, length = 255)
    public String getOutboundStatus() {
        return outboundStatus;
    }

    public void setOutboundStatus(String outboundStatus) {
        this.outboundStatus = outboundStatus;
    }

    @Basic
    @Column(name = "outbound_date", nullable = true)
    public Date getOutboundDate() {
        return outboundDate;
    }

    public void setOutboundDate(Date outboundDate) {
        this.outboundDate = outboundDate;
    }

    @Basic
    @Column(name = "outbound_emp_name", nullable = true, length = 255)
    public String getOutboundEmpName() {
        return outboundEmpName;
    }

    public void setOutboundEmpName(String outboundEmpName) {
        this.outboundEmpName = outboundEmpName;
    }

    @Basic
    @Column(name = "outbound_executor", nullable = true, length = 255)
    public String getOutboundExecutor() {
        return outboundExecutor;
    }

    public void setOutboundExecutor(String outboundExecutor) {
        this.outboundExecutor = outboundExecutor;
    }

    @Basic
    @Column(name = "outbound_executor_date", nullable = true)
    public Date getOutboundExecutorDate() {
        return outboundExecutorDate;
    }

    public void setOutboundExecutorDate(Date outboundExecutorDate) {
        this.outboundExecutorDate = outboundExecutorDate;
    }

    @Basic
    @Column(name = "outbound_no", nullable = true, length = 255)
    public String getOutboundNo() {
        return outboundNo;
    }

    public void setOutboundNo(String outboundNo) {
        this.outboundNo = outboundNo;
    }

    @Basic
    @Column(name = "outbound_note", nullable = true, length = 255)
    public String getOutboundNote() {
        return outboundNote;
    }

    public void setOutboundNote(String outboundNote) {
        this.outboundNote = outboundNote;
    }

    @Basic
    @Column(name = "outbound_customer_name", nullable = true, length = 255)
    public String getOutboundCustomerName() {
        return outboundCustomerName;
    }

    public void setOutboundCustomerName(String outboundCustomerName) {
        this.outboundCustomerName = outboundCustomerName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Outbound outbound = (Outbound) o;
        return outboundId == outbound.outboundId &&
                Objects.equals(outboundTitle, outbound.outboundTitle) &&
                Objects.equals(outboundStatus, outbound.outboundStatus) &&
                Objects.equals(outboundDate, outbound.outboundDate) &&
                Objects.equals(outboundEmpName, outbound.outboundEmpName) &&
                Objects.equals(outboundExecutor, outbound.outboundExecutor) &&
                Objects.equals(outboundExecutorDate, outbound.outboundExecutorDate) &&
                Objects.equals(outboundNo, outbound.outboundNo) &&
                Objects.equals(outboundNote, outbound.outboundNote) &&
                Objects.equals(outboundCustomerName, outbound.outboundCustomerName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(outboundId, outboundTitle, outboundStatus, outboundDate, outboundEmpName, outboundExecutor, outboundExecutorDate, outboundNo, outboundNote, outboundCustomerName);
    }

    @ManyToOne
    @JoinColumn(name = "contract_id", referencedColumnName = "contract_id")
    public Contract getContractByContractId() {
        return contractByContractId;
    }

    public void setContractByContractId(Contract contractByContractId) {
        this.contractByContractId = contractByContractId;
    }

    @ManyToOne
    @JoinColumn(name = "warehouse_id", referencedColumnName = "warehouse_id")
    public Warehouse getWarehouseByWarehouseId() {
        return warehouseByWarehouseId;
    }

    public void setWarehouseByWarehouseId(Warehouse warehouseByWarehouseId) {
        this.warehouseByWarehouseId = warehouseByWarehouseId;
    }

    @OneToMany(mappedBy = "outboundByOutboundId")
    public Collection<OutboundDetail> getOutboundDetailsByOutboundId() {
        return outboundDetailsByOutboundId;
    }

    public void setOutboundDetailsByOutboundId(Collection<OutboundDetail> outboundDetailsByOutboundId) {
        this.outboundDetailsByOutboundId = outboundDetailsByOutboundId;
    }
}
